package com.fecean.aabbc.commons.response;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Response
 *
 * @author: chenfenghai
 * @version: 1.0
 * @date: 2019-12-06 10:08
 * @blame Android Team
 */
public class Response<T> implements Serializable {

    private static final long serialVersionUID = 3437060774871469558L;

    /**
     ** 业务错误编码
     */
    private String code;

    /**
     ** 错误信息，一般用于显示提示
     */
    private String message;

    /**
     ** 错误堆栈
     */
    private String trace;

    /**
     ** 业务返回数据
     */
    private T data;

    /**
     ** 扩展属性，以key、value方式保存
     */
    private Map<String, Object> extend;

    /**
     ** 返回时间戳
     */
    private long timestamp;

    /**
     ** 服务器处理时间（毫秒）
     */
    private long millis;

    public Response(){
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getTrace() {
        return trace;
    }

    public void setTrace(String trace) {
        this.trace = trace;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Map<String, Object> getExtend() {
        return extend;
    }

    public void setExtend(Map<String, Object> extend) {
        this.extend = extend;
    }

    public void setExtend(String key, Object value) {
        if(this.extend == null){
            this.extend = new HashMap<>();
        }
        this.extend.put(key, value);
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public long getMillis() {
        return millis;
    }

    public void setMillis(long millis) {
        this.millis = millis;
    }
}
